import { Component,ViewChild} from '@angular/core';
import { AppVersion, } from 'ionic-native';  // AppVersion-应用程序版本 PhotoViewer-照片查看器

import { NavController, ActionSheetController, ToastController, Slides} from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

export class HomePage {
  // @ViewChild('mySlides') slider: Slides;
  @ViewChild(Slides) slides: Slides;

  public add ="123";
  toppings="";
  app=AppVersion.getPackageName();


  constructor(
    public navCtrl: NavController,
    public actionSheetCtrl: ActionSheetController,
    public toastCtrl: ToastController,

  ) {
  }

  //弹出框
  presentActionSheet() {    //按钮
    let actionSheet = this.actionSheetCtrl.create({
      title: '按钮1',
      buttons: [
        {
          text: '换字',
          role: 'destructive',
          handler: () => {
            this.add="换字啊哈";
          }
        },{
          text: 'Archive',
          handler: () => {
            console.log('Archive clicked');
          }
        },{
          text: '取消',
          role: 'cancel',
          handler: () => {
            console.log('取消-clicked');
          }
        }
      ]
    });
    actionSheet.present();
  }

  //提示框
  presentToast() {
    let toast = this.toastCtrl.create({
      message: 'User was added successfully',
      duration: 1500,
      position: 'top'
    });
    toast.present();
  }

  //下拉刷新
  doRefresh(refresher) {
    console.log('数据加载中...', refresher);
    setTimeout(() => {
      console.log('加载完成');
      refresher.complete();
    }, 2000);
  }

  ngOnInit(){
    setInterval(()=>{
      this.slides.slideNext(350,true);
    },3500);
  }

}
